package com.changgou.web.filter;
/**
 * @author Sherlock
 * @date 2020/3/16
 */
public class URLFilter {

    /**
     * 事先定义好所有要被拦截的uri
     */
    public static String filterPath = "/api/wseckillorder,/api/seckill,/api/wxpay,/api/wxpay/**,/api/worder/**,/api/user/**,/api/address/**,/api/wcart/**,/api/cart/**,/api/categoryReport/**,/api/orderConfig/**,/api/order/**,/api/orderItem/**,/api/orderLog/**,/api/preferential/**,/api/returnCause/**,/api/returnOrder/**,/api/returnOrderItem/**";

    public static boolean hasAuthorize(String urlPath){
        //先将 /**替换成空字符串 再使用 , 切割
        String[] uriStr = filterPath.replace("/**", "").split(",");
        //传入进来的路径是要拦截的路径,返回true
        for (String uri : uriStr) {
            if (urlPath.startsWith(uri)){
                return true;
            }
        }
        //循环结束,还未匹配上,就返回false
        return false;
    }
}
